package com.cw.jeeyt.service.converter.process;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.process.ActRuTaskBo;
import com.cw.jeeyt.dao.model.process.ActRuTaskDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 待办任务转换类
 *
 * @author chenw
 * @date 2019-04-01 14:56:49
 */
public class ActRuTaskConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static ActRuTaskBo do2Bo(ActRuTaskDo model) {
        if (model == null) {
            return null;
        }
        ActRuTaskBo bo = new ActRuTaskBo();
        bo.setId_(model.getId_());
        bo.setRev_(model.getRev_());
        bo.setExecutionId_(model.getExecutionId_());
        bo.setProcInstId_(model.getProcInstId_());
        bo.setProcDefId_(model.getProcDefId_());
        bo.setScopeId_(model.getScopeId_());
        bo.setSubScopeId_(model.getSubScopeId_());
        bo.setScopeType_(model.getScopeType_());
        bo.setScopeDefinitionId_(model.getScopeDefinitionId_());
        bo.setName_(model.getName_());
        bo.setParentTaskId_(model.getParentTaskId_());
        bo.setDescription_(model.getDescription_());
        bo.setTaskDefKey_(model.getTaskDefKey_());
        bo.setOwner_(model.getOwner_());
        bo.setAssignee_(model.getAssignee_());
        bo.setDelegation_(model.getDelegation_());
        bo.setPriority_(model.getPriority_());
        bo.setCreateTime_(model.getCreateTime_());
        bo.setDueDate_(model.getDueDate_());
        bo.setCategory_(model.getCategory_());
        bo.setSuspensionState_(model.getSuspensionState_());
        bo.setTenantId_(model.getTenantId_());
        bo.setFormKey_(model.getFormKey_());
        bo.setClaimTime_(model.getClaimTime_());
        bo.setIsCountEnabled_(model.getIsCountEnabled_());
        bo.setVarCount_(model.getVarCount_());
        bo.setIdLinkCount_(model.getIdLinkCount_());
        bo.setSubTaskCount_(model.getSubTaskCount_());
        bo.setTaskDefId_(model.getTaskDefId_());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static ActRuTaskDo bo2Do(ActRuTaskBo bo) {
        if (bo == null) {
            return null;
        }
        ActRuTaskDo model = new ActRuTaskDo();
        model.setId_(bo.getId_());
        model.setRev_(bo.getRev_());
        model.setExecutionId_(bo.getExecutionId_());
        model.setProcInstId_(bo.getProcInstId_());
        model.setProcDefId_(bo.getProcDefId_());
        model.setScopeId_(bo.getScopeId_());
        model.setSubScopeId_(bo.getSubScopeId_());
        model.setScopeType_(bo.getScopeType_());
        model.setScopeDefinitionId_(bo.getScopeDefinitionId_());
        model.setName_(bo.getName_());
        model.setParentTaskId_(bo.getParentTaskId_());
        model.setDescription_(bo.getDescription_());
        model.setTaskDefKey_(bo.getTaskDefKey_());
        model.setOwner_(bo.getOwner_());
        model.setAssignee_(bo.getAssignee_());
        model.setDelegation_(bo.getDelegation_());
        model.setPriority_(bo.getPriority_());
        model.setCreateTime_(bo.getCreateTime_());
        model.setDueDate_(bo.getDueDate_());
        model.setCategory_(bo.getCategory_());
        model.setSuspensionState_(bo.getSuspensionState_());
        model.setTenantId_(bo.getTenantId_());
        model.setFormKey_(bo.getFormKey_());
        model.setClaimTime_(bo.getClaimTime_());
        model.setIsCountEnabled_(bo.getIsCountEnabled_());
        model.setVarCount_(bo.getVarCount_());
        model.setIdLinkCount_(bo.getIdLinkCount_());
        model.setSubTaskCount_(bo.getSubTaskCount_());
        model.setTaskDefId_(bo.getTaskDefId_());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<ActRuTaskBo> doList2BoList(List<ActRuTaskDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), ActRuTaskConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<ActRuTaskDo> boList2DoList(List<ActRuTaskBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), ActRuTaskConverter::bo2Do));
    }
}